From 1621bd0baf25f77a2f6b7765ee79183f2684bf6e Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Fri, 6 Jan 2017 12:46:56 -0500 Subject: [PATCH] disable color shell tests for terminals that don't support color Some terminals (e.g. running a shell inside Emacs's shell-mode) don't support color, and running tests that assume the terminal supports color don't work so well. Instead, if color is expected, check the terminal for whether it supports color or not, and act accordingly. --- tests/shell.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/shell.rs b/tests/shell.rs index 4b03aa6f6..8dc0786fc 100644 --- a/tests/shell.rs +++ b/tests/shell.rs @@ -62,15 +62,19 @@ fn colored_shell() { shell.say("Hey Alex", color::RED).unwrap(); }); let buf = a.lock().unwrap().clone(); - assert_that(&buf[..], - shell_writes(colored_output("Hey Alex\n", - color::RED).unwrap())); + let expected_output = if term.unwrap().supports_color() { + shell_writes(colored_output("Hey Alex\n", color::RED).unwrap()) + } else { + shell_writes("Hey Alex\n") + }; + assert_that(&buf[..], expected_output); } #[test] fn color_explicitly_enabled() { let term = TerminfoTerminal::new(Vec::new()); if term.is_none() { return } + if !term.unwrap().supports_color() { return } let config = ShellConfig { color_config: Always, tty: false }; let a = Arc::new(Mutex::new(Vec::new())); -- 2.30.2